#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int main()
{
    int y, n;
    cin >> y >> n;
    int day[20] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
        day[2] = 29;
    cout << day[m] << endl;
    return 0;
}